{% extends 'TopxiaAdminBundle::layout.html.twig' %}

{% set menu = 'admin_Promo' %}

{% block main %}
 {{ web_macro.flash_messages() }}
<div class="well well-sm mtl">
    <form id="activema-build-form" class="form-inline" action="{{ path('admin_Promo_build') }}" onsubmit="return cheack()"method="get" novalidate="">
      <div class="form-group">
        <input style="max-width:150px;" class="form-control" id="num"type="text" placeholder="数量" name="num" value="">
      </div>
      <div class="form-group">
        <input style="max-width:150px;" class="form-control" id="mz"type="text" placeholder="面值" name="mz" value="">
      </div>
     
      <div class="form-group">
        <input style="max-width:100px;" class="form-control" id="yxq" type="text" placeholder="有效期(月)" name="yxq" value="">
      </div>
       <div class="form-group">
        <input style="max-width:50px;" class="form-control" type="text" placeholder="批量生成标志" readonly="readonly"name="pc" value="{{ num }}">
      </div>
      <button class="btn btn-primary" >批量生成优惠码</button>
    </form>
</div>
<div class="well well-sm mtl">
    <form id="activema-search-form" class="form-inline" action="" method="get" novalidate="">
      <div class="form-group">
        <input style="max-width:150px;" class="form-control" type="text" placeholder="优惠码" name="promo" value="{{ app.request.get('promo') }}">
      </div>
		<div class="form-group">
        <input style="max-width:70px;" class="form-control" type="text" placeholder="批次" name="pc" value="{{ app.request.get('pc') }}">
      </div>
		<div class="form-group">
        <input style="max-width:70px;" class="form-control" type="text" placeholder="面额" name="mz" value="{{ app.request.get('mz') }}">
      </div>
		<div class="form-group">
			<select name="status" class="form-control">
				<option value="0">未使用</option>
				<option value="1">已使用</option>
			</select>
      </div>
      <button class="btn btn-primary">搜索</button>

    </form>
</div>
<form id="activema-form" class="form-inline" action="{{ path('admin_promo_set') }}" method="get" novalidate="">
<table class = 'table table-striped table-hover'>
<thead>
    <tr>
<!--        <th><input type='checkbox' data-role="batch-select" /></th>--><th>ID</th><th>优惠码</th><th>面值</th><th>截止有效期</th><th>使用状态</th><th>生成批次</th>
  
    </tr>
</thead>
<tbody>
{% for activema in activemas %}
    <tr>
<!--  <td><input type='checkbox' name='ids[]' value = '{{ activema.id }}' data-role="batch-item" /></td>-->
        <td>{{ activema.id }}</td>
        <td>{{ activema.promo }}</td>
        <td>{{ activema.mz }}</td>
        <td>{{ activema.yxqtime|date("Y-m-d") }}</td>
        <td>{% if activema.status==0 %}未使用/{% if time>activema.yxqtime|date("Y-m-d") %}<font color="red">已过期</font>{% else%} <font color="blue">未过期</font>{% endif %}{% else %}<font color="red">已使用/{% if time>activema.yxqtime|date("Y-m-d") %}<font color="red">已过期</font>{% else%} <font color="blue">未过期</font>{% endif %}</font>{% endif %}</td>
        <td>第{{ activema.pc }}批</td>
    </tr>
{% else %}
    <tr><td colspan="15"><div class="empty">暂无优惠码记录</div></td></tr>
{% endfor %}
   
</tbody>
</table>
    <script>
        function cheack(){
			
             var num = document.getElementById("num").value; 
            var mz = document.getElementById("mz").value;
            var yxq = document.getElementById("yxq").value;
            if(num==''){
                alert('数量不能为空');
                return false;
            }else if(mz==''){
                 alert('面值不能为空');
                return false;
            }else if(yxq==''){
                 alert('有效期不能为空');
                return false;
            }
        }
    </script>
{{ web_macro.paginator(paginator) }}
{% endblock %}
